# -*- coding: utf-8 -*-            
# @Author : chenliang
# @Time : 2024/1/5 13:27
from lib2to3.pgen2 import driver

from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from datetime import datetime


class ProductComputingLocator:
   # 等待转菊花
   wait_for_pay = (By.CSS_SELECTOR, '[class="antd4-spin-dot antd4-spin-dot-spin"]')

   """
   my resource 页面
   """
   # my resource tab页面菜单列表
   my_resource_tab_list = (By.CSS_SELECTOR,'[class="antd4-tabs-tab-btn"]')
   # product 列表
   my_resource_product_list = (By.CSS_SELECTOR,'[class="productBtn___2kdzl"]')
   # create_new按钮
   move_computing_create_new = (By.XPATH,'(//button[@class="antd4-btn antd4-btn-primary"])[3]')



   ###################### Auto Scaling #############################################
   """
    Auto Scaling 页面
   """
   # iframe
   iframe_auto_scaling = (By.CSS_SELECTOR,'[id="hj_container"]')
   # 判断进入auto scaling
   if_enter_auto_scaling_page = (By.CSS_SELECTOR,'[class="teamix-nav-sidebar-header-name"]')
   # scaling groups
   click_scaling_groups_page = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis teamix-nav-console-sidebar-text"])[2]')
   # 进入Scaling Groups页面
   if_enter_scaling_group = (By.CSS_SELECTOR,'[class="teamix-pro-page-header-title-name"]')
   # create a Scaling Groups 按钮
   click_create_scaling_group = (By.CSS_SELECTOR,'[class="next-btn next-medium next-btn-primary is-hybridcloud"]')
   # input group name
   input_group_name = (By.CSS_SELECTOR,'[placeholder="Search by scaling group name"]')
   # 点击查询
   click_search_button = (By.XPATH,'//span[text()="Search"]/..')
   # 列表数据总数
   total_data = (By.CSS_SELECTOR,'[class="next-pagination-total"]')
   # first 数据的name
   first_data_group_name = (By.XPATH,'(//div[@class="balloonDiv"])[1]')
   # first 数据的删除
   first_data_delete = (By.XPATH,'//*[text()="Delete"]/..')
   # 确认删除按钮
   click_sure_ok = (By.CSS_SELECTOR,'[class="next-btn next-medium next-btn-primary next-dialog-btn"]')

   """
   Resource Orchestration Service管理控制页
   """
   #iframe
   iframe_resource_orchestration_service = (By.CSS_SELECTOR,'[id="hj_container"]')
   #判断进入Resource Orchestration Service
   if_enter_resource_orchestration_service_page = (By.XPATH,'//*[@id="icestarkNode"]/div[1]/header/section/section[1]/section[1]/div/div[1]/div')
   #判断页面包含Stack ID/Name
   if_stack_id = (By.XPATH,'//*[@id="icestarkNode"]/div[2]/div/div[2]/div[1]/div[2]/div[1]/div[1]/table/thead/tr/th[1]/div/span[1]')
   # 判断页面包含Organization
   if_stack_org = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis"])[2]')
   # 判断页面包含Resource Set
   if_stack_resset = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis"])[3]')
   # 判断页面包含Status
   if_stack_status = (By.XPATH,'(//div[@class="next-table-cell-wrapper"])[4]')
   # 判断页面包含Rollback on Failure
   if_stack_rollback = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis"])[4]')
   # 判断页面包含Timeout Period
   if_stack_timeout = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis"])[5]')
   # 判断页面包含Status description
   if_stack_status_desc = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis"])[6]')
   # 判断页面包含Created At
   if_stack_created = (By.XPATH,'(//div[@class="next-table-cell-wrapper"])[8]')
   # 判断页面包含Updated At
   if_stack_updated = (By.XPATH,'(//div[@class="next-table-cell-wrapper"])[9]')
   # 判断页面包含Actions
   if_stack_actions = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis"])[7]')

   """
   创建stacks
   """
   #点击创建按钮
   click_create_stack = (By.XPATH,'//*[@id="icestarkNode"]/div[2]/div/div[1]/a/span')
   #选择resource_set输入框
   input_resource_set = (By.XPATH,'//*[@id="icestarkNode"]/div/div[2]/div[1]/div/div[2]/div/form/div/div[2]/div/div/div[2]/div[1]/div/div[1]/div[1]/span/span[1]')
   #选择resource_set的值
   select_resource_set_value = (By.XPATH,'/html/body/div[4]/div/ul/li/div/span')
   #选择template
   select_template = (By.XPATH,'//*[@id="templateType"]/label[1]/span[1]/input')
   #输入template
   iframe_input_template = (By.CSS_SELECTOR, '[id="hj_container"]')
   input_template = (By.CSS_SELECTOR, '#template > div.ace_scroller > div')
   #点击下一步
   click_next = (By.XPATH,'//*[@id="icestarkNode"]/div/div[3]/div/button[2]/span')
   #输入name
   input_name = (By.XPATH,'//*[@id="stackName"]')
   #第二次点击下一步
   second_click_next = (By.XPATH,'//*[@id="icestarkNode"]/div/div[3]/div/button[2]/span')
   #第三次点击下一步
   third_click_next = (By.XPATH,'//*[@id="icestarkNode"]/div/div[3]/div/button[2]/span')
   #点击创建提交stack
   click_create_succ = (By.XPATH,'//*[@id="icestarkNode"]/div/div[3]/div/button[2]/span')

   """
      Create Scaling Group 创建页面
   """
   # input Scaling Group Name
   input_scaling_group_name = (By.CSS_SELECTOR,'[id="ScalingGroupName"]')
   # 点击触发org按钮
   click_organization = (By.XPATH,'(//span[@class="next-select-values next-input-text-field"])[2]')
   # org list进行选择
   select_org_list = (By.XPATH,'(//div[@class="next-tree-node-label next-tree-node-label-selectable"])[1]')
   # 确认按钮
   click_ok = (By.XPATH,'(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])[2]')
   # 提交后成功提示语，瞬间
   show_create = (By.CSS_SELECTOR,'[class="next-message-title"]')
   # 判断vSwitch是否存在
   if_vswitch= (By.CSS_SELECTOR,'[class="item-error"]')
   # 点击vpcid
   click_vpcid = (By.XPATH,'(//span[@class="next-select-values next-input-text-field"])[7]')
   # vpcid列表
   vpcid_list = (By.XPATH,'//div[@class="next-overlay-inner next-select-spacing-tb next-select-single-menu"]//ul/li/div/span')
   # 动态获取vpcid_list中的值
   def vpcid_list_num(self,num):
      str_old = '(//div[@class="next-overlay-inner next-select-spacing-tb next-select-single-menu"]//ul/li/div/span)'
      str_new = str_old + '['+num+']'
      return (By.XPATH,str_new)


   """
    Scaling Group Details详细页面 -- basic_information
   """
   # Scaling Group Name
   find_scaling_group_name = (By.XPATH,'(//*[@class="as-info-item-content-cell"])[2]')
   # 退回按钮
   go_back = (By.CSS_SELECTOR,'[class="teamix-icon teamix-icon-return-line teamix-medium back-icon"]')



   ###################### VM #############################################
   """
     VM 控制台页面
   """
   # 检查控制台标题
   check_vm_title = (By.CSS_SELECTOR,'[class="cre-page-container-header-panel-title cre-page-container-header-panel-title-large"]')
   # network菜单
   chick_network_page = (By.XPATH,'(//*[@class="antd4-menu-title-content"])[2]')
   # Add network
   add_network = (By.XPATH,'(//*[@class="antd4-btn antd4-btn-primary"])[1]')
   # 查询条件输入框
   search_input_network_name = (By.XPATH,'(//*[@class="antd4-input"])[2]')
   # network查询按钮
   click_search_network = (By.XPATH, '(//*[@class="antd4-btn antd4-btn-primary"])[2]')
   # network total数
   network_total_data = (By.CSS_SELECTOR,'[class="antd4-pagination-total-text"]')
   # network查询列表第一条数据name值
   network_first_data_name = (By.XPATH,'(//*[@class="cre-table-nowrap"])[1]')
   # 删除network，列表
   delete_network_list = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-link table-operation-btnLine-btn"]')
   # 确认删除按钮
   cilck_network_ok = (By.XPATH,'(//*[@class="antd4-btn antd4-btn-primary"])[3]')
   # sure delete create
   sure_delete_create = (By.XPATH,'//*[@class="antd4-message-custom-content antd4-message-success"]/span[2]')
   # 创建virtual_machine 按钮
   create_virtual_machine = (By.XPATH,'(//*[@class="antd4-btn antd4-btn-primary"])[1]')
   # Virtual Machine List ...操作按钮
   rig_virtual_machine_list = (By.CSS_SELECTOR,'[class="anticon anticon-ellipsis table-operation-ellipsis"]')
   # Virtual Machine List 第一条数据的...操作按钮
   rig_virtual_machine_list_first = (By.XPATH,'(//*[@class="anticon anticon-ellipsis table-operation-ellipsis"])[1]')
   # Virtual Machine release
   click_virtual_machine_release = (By.XPATH,'(//*[@class="antd4-dropdown-menu-title-content"])[7]')
   # 确认virtual_machine删除
   sure_virtual_machine_release_submit = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary antd4-btn-lg releaseBtn___27j7c"]')
   # 确认virtual_machine删除- yes按钮
   sure_virtual_machine_yes_release = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary"]')
   # 判断release
   sure_virtual_machine_release_success = (By.CSS_SELECTOR,'[class="resultTitle___2AfnO"]')
   # 查询条件选择
   click_search_virtual_machine_list = (By.XPATH,'(//*[@class="antd4-select-selection-search"])[1]')
   # 查询条件
   search_virtual_machine_term = (By.CSS_SELECTOR,'[class="antd4-select-item-option-content"]')
   # 输入查询条件
   input_search_term = (By.XPATH,'(//*[@class="antd4-input"])[2]')
   # 点击search
   click_search = (By.XPATH,'(//*[@class="antd4-btn antd4-btn-primary"])[2]')
   # 列表第一条数据的 name
   virtual_machine_list_first_data_name = (By.XPATH,'//*[@class="antd4-table-row antd4-table-row-level-0"]/td[1]/div[2]')
   # 列表第一条数据的 copy
   virtual_machine_list_first_data_copy = (By.CSS_SELECTOR, '[role="button"]')
   # 列表第一条数据的 state
   virtual_machine_list_first_data_state = (By.XPATH, '//*[@class="antd4-table-row antd4-table-row-level-0"]/td[2]/span[2]')
   # 列表第一条数据的 id
   virtual_machine_list_first_data_id = (By.XPATH, '//*[@class="antd4-table-row antd4-table-row-level-0"]/td[1]/div[1]/div/a')
   # 列表第一条数据的 host
   virtual_machine_list_first_data_host = (By.XPATH,'//*[@class="antd4-table-row antd4-table-row-level-0"]/td[3]/div[1]')
   # 列表第一条数据的 cpu
   virtual_machine_list_first_data_cpu = (By.XPATH, '//*[@class="antd4-table-row antd4-table-row-level-0"]/td[4]/div[1]')
   # 列表第一条数据的 Memory
   virtual_machine_list_first_data_memory = (By.XPATH, '//*[@class="antd4-table-row antd4-table-row-level-0"]/td[5]/div[1]')
   # 列表第一条数据的 on_power 按钮
   virtual_machine_list_first_data_on_power = (By.XPATH,'(//*[@class="antd4-dropdown-menu-title-content"])[1]')
   # 列表第一条数据的 off_power 按钮
   virtual_machine_list_first_data_off_power = (By.XPATH,'(//*[@class="antd4-dropdown-menu-title-content"])[2]')
   # 列表第一条数据的 suspend 按钮
   virtual_machine_list_first_data_suspend = (By.XPATH,'(//*[@class="antd4-dropdown-menu-title-content"])[3]')
   # 列表第一条数据的 reboot 按钮
   virtual_machine_list_first_data_reboot = (By.XPATH,'(//*[@class="antd4-dropdown-menu-title-content"])[4]')
   # 列表第一条数据的 reboot 按钮
   virtual_machine_list_first_data_modify_datastore = (By.XPATH, '(//*[@class="antd4-dropdown-menu-title-content"])[6]')
   # 修改power状态确认
   click_power_ok = (By.XPATH,'(//*[@class="antd4-btn antd4-btn-primary"])[3]')
   # 点击reset
   click_reset = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-default"]')
   # 列表查询数量
   list_count = (By.CSS_SELECTOR,'[rel="nofollow"]')
   # 所在地区
   get_now_vcenter = (By.XPATH,'(//div[@class="antd4-space-item"])[2]')

   """
      Basic Information 页面
   """
   # 获取Basic Information页面的数据项
   basic_information_list = (By.CSS_SELECTOR,'[class="cre-descriptions-nowrap"]')
   # 获取Basic Information页面的数据项对应的值
   basic_information_data_list = (By.CSS_SELECTOR,'[class="antd4-descriptions-item-content"]')


   """
      Create Network
   """
   # 输入network name
   input_network_name = (By.CSS_SELECTOR,'[id="creForm_networkName"]')
   # submit按钮
   click_network_submit = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary"]')
   # 新增加后判断是否增加成功提示语
   check_add_network_create = (By.XPATH,'//*[@class="antd4-message-custom-content antd4-message-success"]/span[2]')
   # 超过创建上线提示
   create_on_line_cue = (By.CSS_SELECTOR,'[class="ant-message-custom-content ant-message-warning"]')

   """
      create Vmware Virtual Machine
   """
   # 页面抬头判断
   sure_into_vmware_virtual_machine = (By.XPATH,"(//*[text()='Vmware Virtual Machine'])[2]")
   # input name
   input_vmware_virtual_machine_name = (By.CSS_SELECTOR,'[id="creForm_instanceName"]')
   # Terms of Service
   tick_terms_of_service = (By.CSS_SELECTOR,'[class="antd4-checkbox"]')
   # Buy Now
   click_buy_now = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary"]')
   #
   # 动态获取datastore列表数据项值
   def get_datastore_data(self,num):
      str_old = '(//*[@class="antd4-table-thead"])[2]/tr/th'
      if num =='5':
         str_new = str_old + '['+num+']'+'/div/span[1]'
      else:
         str_new = str_old + '['+num+']'
      return (By.XPATH,str_new)
   # Capacity满了提示语校验
   capacity_full_clue = (By.XPATH,"//*[text()='The capacity you have selected has exceeded the total available capacity']")
   # 添加数据库的列表值
   add_disk_list = (By.CSS_SELECTOR,'[class="antd4-input-number-input"]')
   # Available/Total Storage
   datastore_available_total_storage = (By.XPATH,'(//*[@class="antd4-table-tbody"])[2]/tr/td[4]/div')
   # 点击cpu
   click_instance_type_cpu = (By.XPATH,'//*[@id="cpu"]/..')
   # cpu列表
   instance_type_cpu_list = (By.XPATH,'//*[@id="cpu_list"]/../div[2]/div[1]/div/div/div//*[@class="antd4-select-item-option-content"]')
   # 查询cpu 交验
   check_instance_type_cpu_list = (By.XPATH,'(//*[@class="antd4-table-tbody"])[1]/tr/td[3]//*[@class="cre-table-nowrap"]')
   # 点击memory
   click_instance_type_memory = (By.XPATH, '//*[@id="memory"]/..')
   # memory列表
   instance_type_cpu_memory = (By.XPATH, '//*[@id="memory_list"]/../div[2]/div[1]/div/div/div//*[@class="antd4-select-item-option-content"]')
   # 查询memory 交验
   check_instance_type_memory_list = (By.XPATH, '(//*[@class="antd4-table-tbody"])[1]/tr/td[4]//*[@class="cre-table-nowrap"]')
   # 默认选择的第一条实例定价
   first_instance_pricing = (By.XPATH,'((//*[@class="antd4-table-tbody"])[1]//td[@class="antd4-table-cell"][4])[1]')
   # Calculating price... 计算中
   calculating_price = (By.XPATH,'//*[text()="Calculating price..."]')
   # 系统估算值
   costs = (By.XPATH,'//*[@class="balance___1syIz undefined"]')





   """
     Payment 支付页面
   """
   # click_payment_pay
   click_payment_pay = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary footerBtn___3GAsr"]')
   # 等待提交动画
   wait_for_submit= (By.CSS_SELECTOR,'[class="antd4-spin-dot antd4-spin-dot-spin"]')
   # Payment Successful
   payment_successful = (By.CSS_SELECTOR,'[class="antd4-result-title"]')
   # 判断进入Payment页面
   sure_enter_into_payment = (By.CSS_SELECTOR,'[class="cre-page-container-header-panel-title cre-page-container-header-panel-title-default"]')
   # Detail
   move_to_detail = (By.CSS_SELECTOR,'[class="handleText___1yK3p"]')
   # Detail Instance Name
   detail_instance_name = (By.XPATH,'//span[@class="handleText___1yK3p"]/../div/div/div[2]/div[2]')




   """
      Change Datastore 页面    
   """
   # Change Datastore页面标题判断
   titel_change_datastore = (By.CSS_SELECTOR,'[class="title___2q0Qh"]')
   # add disk
   click_add_disk = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-dashed"]')
   # input disk 容量
   input_disk_capacity = (By.XPATH,'(//*[@aria-valuemin="1"])[2]')











